package untils

import (
	"fmt"
	"github.com/smartwalle/alipay/v3"
)

// 封装工厂模式
type Pay interface {
	Payment() string
}

// 支付宝、
type ZhiFuBao struct {
}

func (z *ZhiFuBao) Payment(outTradeNo, totalAmount string) string {
	var privateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCpS1DXMoptqRW2021JoB4/Gw1Igrr0RFckUMaorUKQ7+4nIk6po6YqwFWJD+LhCcUPSt4JMylOTDxOto71mu51yfMNHyH+1E759HGDcSpZkDJxq0Wxp/o4JGXNpgqW1e7+2bIHyErojYuxJggt5ldPAa2/NTEqYHqpl0QGOhoacBfOe3S3ddgtINE36T+IhVKlikSdqKSNzouuPFgJaeTp7lqc43mEeEN/tBT/S+Owu0hoMT3Utj847PLDORHJTGZYU5QFcpPn+PEfIYnp90gMJgfTICVxDp+PnRjAQ+G7tV2V2ih/Q85+glCZb5X28ZpNNGYWaf2mgm09C1RKcm/9AgMBAAECggEAb0ACKNiapUOW9GTuDZL+LWQej4bxSnHafg/i7JenBc3Vx7vAy7OyD6gCzaY15sJf0BPX413OiBiLDQLk4Ttl9tu2L+pEkcx89b8QFVt5hA/BRndRvlRvlxM8Hy89CDAf9TOjzX9u0nGp2cjvWRJkT5P/1IYk//8UvHueBSWLX9E1Q9CfVPTIJjXD26MBkdUOGuqV4Q35jcCNm/MmGntjT9YCdvps/zSdNYfPgXXH/JvCChIIKQ5/3sXHDknJzhrD8lWo3FUcPaEZc7gi+4F1XJgPZcJ69jHdgnbXTdgPx9K09Z83vsyxfnyO+Uqt84MFJ1Ir1ZBu99WttHUXlHIGVQKBgQDgUGw0IRTIYL+kPyfX8oTlnRKCBlUiyijDbqE5XIOEq0pFmp1MdvH2nFFqGlmm+ezg8LVXPVklQW9f/hKnO5e5cggIOYMjdmAwEJWGosUM2+36J7vGXuj1MWCOAHx5Qg+aoOIvf2d/VGRrUxrb989Pousr5pGhIbYORwZ63vcBcwKBgQDBNUd1xFhdW9H6lgdUzyC+uw7YgnZ8LB9nptvMc3tQ0vQT4q/peyZ9JIEaDkHErI9YDeuILbgN8ieaXc+EW6nzoqJiVe/H1NPc77Lm1k0ERPMtfXGlgADfW+Ltnw9LOvNrEEmJgmq+OCywI+LgFgmHrj4zKAz5/dlBO643yYWszwKBgQCNmdckdTmkYIa5zXB+fsbsF+KmGA9IXeurqzu1dTRE3MiO9dKUgYWvEvDGFQpBQQYK3YjsIHsU7KC9LStjTFg0JcryPjQNf92qmd16V2gi/PbWcpyz1hgjKF92ZNIuzcgB6cu/BiM0mvalVZngAChrckIYvX1zBU/i5W0uxW+SBwKBgQC5IWFI0gvN4Sax00JRHGuG9tyBz3jTAMBS5IqmPF2EE672wvbGZU97CBiAq/qPBr4PpL70bMJ48njKLGukquSNZF/uk+O/egpMII4vLFb96UeOZi4YZC/x1iz6fbf84Q7PnvqnvYSkolUHrks9Z0BYdzh4cj8E6B1dqV8Fa58f9wKBgE0N36VGB2w0K4q1Euh4RPn9ZGtBHqoqjChqgkK6g47T0wTqYs0uHGdYReZbiRTChxDEBXNT3brFLiItpwzss2VVh9ry2Ka/4FJDRYsuVMrkx3ZitKPUkXn6I3hl+iGRtCzV2MDT3eP/bt5kHAUgk7HNTWnGuPjGO5H/LGthqU5L" // 必须，上一步中使用 RSA签名验签工具 生成的私钥
	addId := "2021000148652086"
	var client, err = alipay.New(addId, privateKey, false)
	if err != nil {
		fmt.Println(err)
	}
	var p = alipay.TradeWapPay{}
	p.NotifyURL = "http://www.baidu,com"
	p.ReturnURL = "http://www.baidu,com"
	p.Subject = "家政支付平台"
	p.OutTradeNo = outTradeNo
	p.TotalAmount = totalAmount
	p.ProductCode = "QUICK_WAP_WAY"

	url, err := client.TradeWapPay(p)
	if err != nil {
		fmt.Println(err)
	}

	// 这个 payURL 即是用于打开支付宝支付页面的 URL，可将输出的内容复制，到浏览器中访问该 URL 即可打开支付页面。
	var payURL = url.String()
	fmt.Println(payURL)
	return payURL
}

// 微信
type WeiXin struct {
}

func (w *WeiXin) Payment(outTradeNo, totalAmount string) string {
	return ""
}
